package com.selfdriving.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.selfdriving.BaseApplication;
import com.selfdriving.BaseObjectListAdapter;
import com.selfdriving.R;
import com.selfdriving.bean.Entity;
import com.selfdriving.bean.MyGroups;

public class WMyGroupsAdapter extends BaseObjectListAdapter
{
	BaseApplication application;
	Context context;
	List<? extends Entity> datas;
	protected DisplayImageOptions options;

	public WMyGroupsAdapter(BaseApplication application, Context context,
			List<? extends Entity> datas)
	{
		super(application, context, datas);
		this.application = application;
		this.context = context;
		this.datas = datas;
		options = new DisplayImageOptions.Builder().cacheInMemory(true)
				.cacheOnDisc(true).considerExifParams(true)
				.bitmapConfig(Bitmap.Config.RGB_565).build();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if (convertView == null)
		{
			convertView = mInflater.inflate(R.layout.w_item_my_groups, null);
			holder = new ViewHolder();
			holder.img = (ImageView) convertView
					.findViewById(R.id.item_my_groups_icon);
			holder.name = (TextView) convertView
					.findViewById(R.id.item_my_groups_name);
			convertView.setTag(holder);
		} else
		{
			holder = (ViewHolder) convertView.getTag();
		}
		MyGroups myGroups = (MyGroups) datas.get(position);
		holder.img.setImageResource(R.drawable.list_grouphead_normal);
		holder.name.setText(myGroups.getName());
		return convertView;
	}

	class ViewHolder
	{
		ImageView img;
		TextView name;
	}
}
